home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / find.asm < prev    next >
Assembly Source File  |  1985-06-03  |  2KB  |  69 lines

  1.         NAME    FIND
  2.         TITLE    Find file and attributes
  3.         PAGE    66, 132
  4.  
  5. DGROUP    GROUP    DATA
  6. DATA    SEGMENT    WORD    PUBLIC    'DATA'
  7.     ASSUME    DS:DGROUP
  8.     ASSUME    ES:DGROUP
  9. DATA    ends
  10.  
  11. PGROUP    GROUP PROG
  12. PROG    segment    byte public 'PROG'
  13.     assume    cs:PGROUP
  14.  
  15.  
  16.         PUBLIC    FIND1ST, FINDNEXT
  17.  
  18. FIND1ST     PROC    NEAR
  19. ;
  20. ;    This procedure finds the first file that matches the name and set of
  21. ;    attributes passed in.  If the file is found, a pointer to the information
  22. ;    block is returned, otherwise, zero is returned.
  23. ;
  24. WILDCARD    EQU    WORD PTR [BP + 4]
  25. ATTR_MASK    EQU    WORD PTR [BP + 6]
  26. DTA_P        EQU    WORD PTR [BP + 8]
  27.  
  28.         push    bp
  29.         mov    bp, sp
  30.         mov    dx, DTA_P            ; point to info block
  31.         mov    ah, 1Ah             ; request new DTA
  32.         int    21h                ; from MSDOS
  33.         mov    dx, WILDCARD            ; filename to find
  34.         mov    cx, ATTR_MASK            ; with these attributes
  35.         mov    ah, 4Eh             ; request search
  36.         int    21h                ; of DOS
  37.         mov    ax, 0                ; assume 0 (failure)
  38.         jc    DONE                ; if CY, no match
  39.         inc    ax                ; else success
  40. DONE:        pop    bp
  41.         ret
  42. FIND1ST     ENDP
  43.  
  44. FINDNEXT    PROC    NEAR
  45. ;
  46. ;    This procedure finds the next file that matches the name and set of
  47. ;    attributes passed in to FIND1ST.  This routine uses the information block
  48. ;    pointer that was passed to FIND1ST, and no changes to the block may
  49. ;    have taken place.    FINDNEXT false (0) when there are no more matches.
  50. ;
  51. INFO_BLOCK    EQU    WORD PTR [BP + 4]
  52.  
  53.         push    bp
  54.         mov    bp, sp
  55.         mov    dx, INFO_BLOCK            ; point to info block
  56.         mov    ah, 1Ah             ; request new DTA
  57.         int    21h                ; from MSDOS
  58.         mov    ah, 4Fh             ; request search
  59.         int    21h                ; of DOS
  60.         mov    ax, 0                ; assume 0 (failure)
  61.         jc    QUIT                ; if CY, no match
  62.         inc    ax                ; else TRUE (success)
  63. QUIT:        pop    bp
  64.         ret
  65. FINDNEXT    ENDP
  66.  
  67. PROG        ENDS
  68.         END
  69.